home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / POLCOF.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-29  |  837b  |  34 lines

  1. PROCEDURE polcof(xa,ya: glnarray; n: integer; VAR cof: glnarray);
  2. (* Programs using routine POLCOF must define the type
  3. TYPE
  4.    glnarray = ARRAY [1..n] OF real;
  5. in the main routine. *)
  6. VAR
  7.    k,j,i: integer;
  8.    xmin,dy: real;
  9.    x,y: glnarray;
  10. BEGIN
  11.    FOR j := 1 TO n DO BEGIN
  12.       x[j] := xa[j];
  13.       y[j] := ya[j]
  14.    END;
  15.    FOR j := 1 TO n DO BEGIN
  16.       polint(x,y,n+1-j,0.0,cof[j],dy);
  17.       xmin := 1.0E38;
  18.       k := 0;
  19.       FOR i := 1 TO n+1-j DO BEGIN
  20.          IF (abs(x[i]) < xmin) THEN BEGIN
  21.             xmin := abs(x[i]);
  22.             k := i
  23.          END;
  24.          IF (x[i] <> 0.0) THEN y[i] := (y[i]-cof[j])/x[i]
  25.       END;
  26.       IF (k < (n+1-j)) THEN BEGIN
  27.          FOR i := k+1 TO n+1-j DO BEGIN
  28.             y[i-1] := y[i];
  29.             x[i-1] := x[i]
  30.          END
  31.       END
  32.    END
  33. END;
  34.